package y2017.date0226pm.颜色表注释调整;

import java.io.*;

public class ReadServer {

    private ReadServer() {
    }

    public static ReadServer getServer() {
        return new ReadServer();
    }

    public String readFileToString(String path) {
        File file = new File(path);
        StringBuilder sb = new StringBuilder();
        try {
            InputStream fis = new FileInputStream(file);
            InputStreamReader isr = new InputStreamReader(fis, "gbk");
            BufferedReader br = new BufferedReader(isr);
            char[] ch = new char[1024];
            int len = 0;

            while ((len = br.read(ch)) != -1) {
                sb.append(ch, 0, len);
            }
            br.close();
            isr.close();
            fis.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}
